//package com.example.myapplication;
//
//import android.view.LayoutInflater;
//import android.view.View;
//import android.view.ViewGroup;
//import android.view.WindowManager;
//import android.widget.RelativeLayout;
//import android.widget.Toast;
//
//import androidx.annotation.NonNull;
//import androidx.appcompat.widget.AppCompatImageView;
//import androidx.appcompat.widget.AppCompatTextView;
//import androidx.recyclerview.widget.RecyclerView;
//
//import com.bumptech.glide.Glide;
//
//
//import org.json.JSONException;
//import org.json.JSONObject;
//
//import java.util.ArrayList;
//
//public class GoodsListHorAdapter extends RecyclerView.Adapter<GoodsListHorAdapter.ViewHolder> {
//
//    private final ArrayList<JSONObject> arrayList;
//
//    public GoodsListHorAdapter(ArrayList<JSONObject> arrayList) {
//
//        this.arrayList = arrayList;
//
//    }
//
//    @Override
//    public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
//
//        //在此处 写 每一个子项需要执行的操作
//        JSONObject jsonObject = arrayList.get(position);
//        try {
//            //加载图片
//            Glide.with(holder.mainImageView).load(jsonObject.getString("goods_image_url")).into(holder.mainImageView);
//            holder.nameTextView.setText(jsonObject.getString("goods_name"));
//            holder.priceTextView.setText("￥" + jsonObject.getString("goods_price"));
//            holder.storeTextView.setText(jsonObject.getString("store_name"));
//            if (jsonObject.getString("is_own_shop").equals("1")) {
//                holder.ownShopTextView.setVisibility(View.VISIBLE);
//                holder.storeTextView.setVisibility(View.INVISIBLE);
//            } else {
//                holder.ownShopTextView.setVisibility(View.INVISIBLE);
//                holder.storeTextView.setVisibility(View.VISIBLE);
//            }
//
//            int width = (App.get().getWidth() - 32) / 2;
//            RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams)holder.mainImageView.getLayoutParams();
//            layoutParams.height = width;
//            holder.mainImageView.setLayoutParams(layoutParams);
//
//        } catch (JSONException e) {
//            e.printStackTrace();
//        }
//
//    }
//
//    @NonNull
//    @Override
//    public ViewHolder onCreateViewHolder(@NonNull ViewGroup group, int viewType) {
//        View view = LayoutInflater.from(group.getContext()).inflate(R.layout.item_goods_list_hor, group, false);
//        return new ViewHolder(view);
//    }
//
//    @Override
//    public int getItemCount() {
//
//        return arrayList.size();
//
//    }
//
//    static class ViewHolder extends RecyclerView.ViewHolder {
//
//        private final AppCompatImageView mainImageView;
//        private final AppCompatTextView nameTextView;
//        private final AppCompatTextView priceTextView;
//        private final AppCompatTextView storeTextView;
//        private final AppCompatTextView ownShopTextView;
//
//        private ViewHolder(View view) {
//
//            super(view);
//            mainImageView = view.findViewById(R.id.mainImageView);
//            nameTextView = view.findViewById(R.id.nameTextView);
//            priceTextView = view.findViewById(R.id.priceTextView);
//            storeTextView = view.findViewById(R.id.storeTextView);
//            ownShopTextView = view.findViewById(R.id.ownShopTextView);
//
//        }
//
//    }
//
//}
